import axios from './axios'
import qs from 'qs'

export function getContractList() {
    return axios.get('/import_and_export/manage/consignment_order_list.do').then(res => Promise.resolve(res.data))
}

export function addContract({contractNumber, contractDateStr, customer, transportMethod, marks, consignmentOrderDetails, totalPrice,belongModule}) {
    const data = qs.stringify({
        contractNumber,
        contractDateStr,
        customer,
        transportMethod,
        marks,
        consignmentOrderDetails,
        totalPrice,
        belongModule
    });
    return axios.post('/import_and_export/manage/save_consignment_order.do', data).then(res => Promise.resolve(res.data));
}


export function modContract({id, contractNumber, contractDateStr, customer, transportMethod, marks, consignmentOrderDetails, totalPrice,belongModule}) {
    const data = qs.stringify({
        id,
        contractNumber,
        contractDateStr,
        customer,
        transportMethod,
        marks,
        consignmentOrderDetails,
        totalPrice,
        belongModule
    });
    return axios.post('/import_and_export/manage/update_consignment_order.do', data).then(res => Promise.resolve(res.data));
}

export function contractFile(formData) {
    return axios.post('/import_and_export/manage/excel_consignment_order', formData, {
        headers: {'Content-Type': 'multipart/form-data'}
    }).then(res => Promise.resolve(res.data));
}

export function partExcelFile(formData) {
    return axios.post('/features_for_heli/manage/excel_features_for_heli', formData, {
        headers: {'Content-Type': 'multipart/form-data'}
    }).then(res => Promise.resolve(res.data));
}

export function showExtraPartList() {
    return axios.get('/features_for_heli/manage/show_list.do').then(res => Promise.resolve(res.data))
}
export function getExtraDetail(orderId) {
    return axios.get('/features_for_heli/manage/show_features_detail.do?orderId='+ orderId).then(({data}) => Promise.resolve(data))
}
export function addExtraPart(partInfo) {
    return axios.post('/features_for_heli/manage/add_features_for_heli.do',qs.stringify(partInfo)).then(({data}) => Promise.resolve(data))
}

export function updateExtraPart(partInfo) {
    return axios.post('/features_for_heli/manage/update_features_for_heli.do',qs.stringify(partInfo)).then(({data})=>Promise.resolve(data))
}


export function getContractDetail(consignmentOrderId) {
    return axios.post('/import_and_export/manage/show_consignment_order.do', qs.stringify({consignmentOrderId})).then(res => Promise.resolve(res.data));
}


//进出口
export function getExportList() {
    return axios.get('/spare_parts_export/manage/show_export_list.do').then(res => Promise.resolve(res.data));
}

export function addExport(exp) {
    return axios.post('/spare_parts_export/manage/save_spare_parts_export.do', qs.stringify(exp)).then(res => Promise.resolve(res.data));
}

export function modExport(exp) {
    return axios.post('/spare_parts_export/manage/update_spare_parts_export.do', qs.stringify(exp)).then(res => Promise.resolve(res.data))
}

//进口
export function addImport(imp) {
    return axios.post('/spare_import/manage/add_spare_import.do', qs.stringify(imp)).then(res => Promise.resolve(res.data));
}

export function getImportList() {
    return axios.get('/spare_import/manage/get_spare_import_list.do').then(res => Promise.resolve(res.data));
}

export function getInventory({pageSize, pageNum, systemName, hostNumber, warning, warehouse, partsNumber, description, belongModule}) {
    return axios.post('/optimization_inventory/manage/shanqi_spare_parts_inventory.do', qs.stringify({
        pageSize,
        pageNum,
        warehouse,
        partsNumber,
        description,
        belongModule,
        systemName,
        hostNumber,
        warning,
    })).then(res => Promise.resolve(res.data))
}
// export function getInventory({pageSize, pageNum, systemName, hostNumber, warning, warehouse, partsNum, description, belongModule}) {
//     return axios.post('/warehouse/manage//select_spare_part_by_warehouse.do', qs.stringify({
//         pageSize,
//         pageNum,
//         warehouse,
//         partsNum,
//         description,
//         belongModule,
//         systemName, hostNumber, warning,
//     })).then(res => Promise.resolve(res.data))
// }


export function getStockOutDetail(search) {
    return axios.post('/shan_qi/manage/select_all_detail.do', qs.stringify(search)).then(res => Promise.resolve(res.data))
}

export function getStorageRecord(partsId, belongModule) {
    return axios.post('/shan_qi/manage/stock_change_detail.do', qs.stringify({
        partsId,
        belongModule
    })).then(res => Promise.resolve(res.data))
}

//发运
export function getDeliveryList(status) {
    return axios.post('/send_goods/manage/show_send_goods_list.do', qs.stringify({status})).then(res => Promise.resolve(res.data))
}

export function addDelivery(delivery) {
    return axios.post('/send_goods/manage/save_send_goods_order.do', qs.stringify(delivery)).then(res => Promise.resolve(res.data))
}

export function modDelivery(delivery) {
    return axios.post('/send_goods/manage/update_send_goods_order.do', qs.stringify(delivery)).then(res => Promise.resolve(res.data))
}

export function getDeliveryDetail(id) {
    return axios.post('/send_goods/manage/show_send_goods_order_detail.do', qs.stringify({id})).then(res => Promise.resolve(res.data))
}

export function uploadPackageList(formData) {
    return axios.post('/send_goods/manage/excel_packing_list.do', formData, {
        headers: {"Content-Type": "multipart/form-data"}
    }).then(res => Promise.resolve(res.data))
}

export function uploadSendingList(formData) {
    return axios.post('/send_goods/manage/excel_sending_goods.do', formData, {
        headers: {"Content-Type": "multipart/form-data"}
    }).then(res => Promise.resolve(res.data))
}

//陕汽发云船号
export function getShipInfo() {
    return axios.get('/spare_parts_export/manage/show_ship_list.do').then(res => Promise.resolve(res.data))
}

export function shipDetail(shipInformation) {
    return axios.post('/spare_parts_export/manage/select_by_ship.do', qs.stringify({shipInformation})).then(res => Promise.resolve(res.data))
}

export function getShacStock(searchDate) {
    return axios.get(`/shacman_statistical/manage/get_shacman_statistical_by_day.do?searchDate=${searchDate}`).then(res => Promise.resolve(res.data))

}